load("@ros2//:ros_cc.bzl", "ros_cc_test")

# Dependencies for both static and shared libraries that will not violate ODR.
cc_library(
    name = "odr_safe_deps",
    visibility = ["//:__subpackages__"],
    deps = [
        "//core:odr_safe_deps",
        "@ros2//:geometry_msgs_cc",
        "@ros2//:rclcpp_cc",
        "@ros2//:tf2_ros_cc",
    ],
)

# TODO(sloretz) more granular targets for static linking
cc_library(
    name = "tf2",
    srcs = glob(
        [
            "*.cc",
            "*.h",
        ],
    ),
    hdrs = glob(
        ["*.h"],
    ),
    include_prefix = "drake_ros/tf2",
    visibility = ["//visibility:public"],
    deps = [
        ":odr_safe_deps",
        "//core",
        "@drake//geometry:scene_graph_inspector",
        "@drake//multibody/plant",
    ],
)

ros_cc_test(
    name = "test_tf_broadcaster",
    size = "small",
    srcs = ["test/test_tf_broadcaster.cc"],
    rmw_implementation = "rmw_cyclonedds_cpp",
    deps = [
        ":tf2",
        "@com_google_googletest//:gtest_main",
        "@drake//common",
        "@drake//systems/primitives",
        "@ros2//:geometry_msgs_cc",
        "@ros2//:rclcpp_cc",
        "@ros2//:tf2_ros_cc",
        "@ros2//resources/rmw_isolation:rmw_isolation_cc",
    ],
)
